package com.irdstudio.efp.esb.api.util;


import com.irdstudio.basic.framework.core.constant.DateFormatConstant;

import java.text.SimpleDateFormat;
import java.text.ParseException;


/**
 * 日期时间工具类
 * @author dengqiwen
 *
 */
public class TimeCompareUtil {


    private static SimpleDateFormat sdf1 = new SimpleDateFormat(DateFormatConstant.TIME_FORMAT);

    /**
     * 判断某个时间点是否在区间范围内<br>
     * 日期格式：HH:mm:ss<br>
     * 返回结果：在区间范围内返回1，不在则返回-1。
     *
     * @param date1
     * @param date2
     * @return
     * @throws Exception
     */
    public static boolean compareTime(String date1, String date2,String date3) throws Exception {
        boolean result = false;
        try {
            long d1 = sdf1.parse(date1).getTime();
            long d2 = sdf1.parse(date2).getTime();
            long d3 = sdf1.parse(date3).getTime();
            if (d1 <= d2 && d2<=d3) {
                result = true;
            }
        } catch (ParseException e) {
            throw new Exception(e);
        }
        return result;
    }


}
